/**
 * 
 */
package web.actions;

import java.io.File;
import java.io.FileOutputStream;

import org.apache.commons.fileupload.FileItem;
import org.mentawai.core.BaseAction;

import facade.Facade;




/**
 * Fazo o upload do arquivo com os usuarios.
 * @author thiagoepdc
 */
public class CadastraUsuarios extends BaseAction {

	/* (non-Javadoc)
	 * @see org.mentawai.core.Action#execute()
	 */
	public String execute() throws Exception {
		FileItem item = (FileItem) input.getValue("file");
		File temp = File.createTempFile("user", "tmp");
		FileOutputStream outFiLE = new FileOutputStream(temp);
		outFiLE.write(item.get());
		outFiLE.close();
		//passar pra facade
		Facade facade = (Facade) input.getValue("facade");
		facade.cadastraUsuarios(temp.getAbsolutePath());
		return SUCCESS;
	}

}
